# Import Module
from tkinter import *

# create root window
root = Tk()

# root window title and dimension
root.title("tkinter学习")
# Set geometry(widthxheight)
root.geometry('800x600')

# 创建标签
label = Label(root, text="你喜欢的编程语言:", font=("Arial", 12))
label.pack(pady=10)

# 创建变量来存储复选框状态
python_var = BooleanVar()
java_var = BooleanVar()
cpp_var = BooleanVar()

# 创建复选框
python_cb = Checkbutton(root, text="Python", variable=python_var, font=("Arial", 11))
java_cb = Checkbutton(root, text="Java", variable=java_var, font=("Arial", 11))
cpp_cb = Checkbutton(root, text="C++", variable=cpp_var, font=("Arial", 11))

# 放置复选框
python_cb.pack()
java_cb.pack()
cpp_cb.pack()

# 创建按钮来显示选择结果
def show_selection():
    result = "你选择了: "
    if python_var.get():
        result += "Python "
    if java_var.get():
        result += "Java "
    if cpp_var.get():
        result += "C++"
    result_label.config(text=result)

# 创建显示结果的标签
result_label = Label(root, text="", font=("Arial", 11))
result_label.pack(pady=10)

# 创建按钮
Button(root, text="显示选择", command=show_selection).pack(pady=5)

# Execute Tkinter
root.mainloop()
